define(
		[ "PDAppDir/properties", "PDUtilDir/util", "PDUtilDir/tool", "PDUtilDir/slidebar",
				"PDUtilDir/inputSelect",
				"PDUtilDir/fileupload/singleFileUpload", "Date", "DateCN",
				"css!DateCss", "PicView", "css!picViewCss",
				"css!AppPathDir/account/accountInfos/views/css/css" ],
		function(Properties, Util, Tool, Slidebar, inputSelect, MFU) {
			function updateSupportInit($scope, $compile) {
				return new updateSupport($scope, $compile);
			}
			function updateSupport($scope, $compile) {
				var _this = this;
				this.entity = {};
				this.bind = {};
				this.$scope = $scope;
				this.$compile = $compile;
			}
			updateSupport.fn = updateSupport.prototype;
			updateSupport.fn.digest = function() {
				this.$scope.$digest();
			}
			updateSupport.fn.run = function(data) {
				var _this = this;
				_this.entity = $.extend({
						person_phone: data.personPhone,
						person_name: data.personName,
						account_number: data.accountNumber,
				}, data);
				_this.bind.src = Properties.URL_FILE_SERVER_URL + _this.entity.qrCodePath;
				_this.entity.image = {
						resouceId: data.qrCodeId,
						path: data.qrCodePath
				}
				this.slidebars = Slidebar({
					size : 'lg',
					url : getServer()
							+ "/static/app/account/accountInfos/views/update.html",
//					close : true,
					$scope : this.$scope,
					$compile : this.$compile,
					afterLoad : function($Panel) {
						_this.initialization();
						_this.digest();
					}
				});
			};
			updateSupport.fn.initialization = function() {
				var _this = this;
				// 初始化支付类型下拉框
				inputSelect.dropCache();
				inputSelect({
					id : "typeName",
					key : {
						id : "dictCode",
						name : "dictName",
						data : "data",
					},
					data : _this.$scope.cache.types,
					initData:[_this.entity.type],
					simpleData : true,
					searchAble : false,
					callback : function(id) {
						_this.entity.type = id[0];
						_this.$scope.updateAccountForm.type.$setViewValue(_this.entity.type);
					}
				});
				MFU.init({
	                placeAt:"account_upload",
	                allowDelete:true,
	                allowMC:true,
	                onUploadSuccess:function(file){
	                	_this.entity.image = {'key':file.name, 'resouceId':file.swordFileId,'path':file.swordFilePath};
	                	_this.digest();
	                },
	                onDeleteSavedFile:function(file){
                        if(file == null) {
                            return;
                        }
	                	_this.removeImg();
	                    _this.digest();
	                },
	                onFileQueued: function(file){
                        if(ImageSuffix.indexOf(file.ext.toLowerCase()) < 0){
                            Util.alert(ImageSuffixNotSupport);
                            this.remove();
                            return;
                        }

	                	this.webUploader.makeThumb(file, function( error, src ) {
	                        if ( error ) {
	                        	Util.alert('不能预览');
	                            return;
	                        }
	                        _this.bind.src = src;
	                        _this.digest();
	                    }, 500, 300 );

	                	this.webUploader.upload();
	                }
	            });
			};
			updateSupport.fn.removeImg = function(resouceId) {
				if(resouceId == this.entity.image.resouceId){
                    this.entity.image = {};
                    this.bind.src = undefined;
                    this.$scope.updateAccountForm.images.$setViewValue('');
				}
			};
			updateSupport.fn.save = function() {
				var _this = this;
				$.ajax({
					url : getServer() + "/flea/hclv/qr/manage/update.htmls",
					data : {
						'model' : JSON.stringify(_this.entity)
					},
					success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
						_this.$scope.gridFun();
						Util.alert(data.message);
						_this.slidebars.close();
					}
				});
			};
			return updateSupportInit;
		});